﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MagicFight
{
    public class Counter : Magic
    {
        int radius = Def.CounterDef.Radius;
        int pointGain = Def.CounterDef.PointGain;

        public Counter(Character caster)
            : base(caster, Def.CounterDef.N)
        {
        }

        public override void Effect(GameTime gameTime)
        {
            alive = false;
            ps.effectsManager.Add(new DrainAura(caster.position));
            foreach (GameObject obj in ps.gameObjects)
            {
                if (obj == null) continue;
                if (!obj.alive) continue;
                if (!(obj is Character)) continue;
                if (obj == caster) continue;
                if (Vector2.Distance(caster.position, obj.position) < radius)
                {
                    Character charTarget = obj as Character;
                    if (charTarget.isCasting)
                    {
                        charTarget.countered = true;
                        caster.AddPoints(type, pointGain);
                        ps.effectsManager.Add(new FloatingText(charTarget.position, "Counter", Color.Blue));
                        Log.Add(caster.name + " cancelou o cast de " + charTarget.name);
                    }
                }
            }

        }
    }
}
